<!--
  @author: crissy-月下闲人
-->

<script lang="ts" setup>
import { AVATAR_URL } from '@/config/index'
import Floating from '@/components/Floating.vue'

const { safeAreaInsets } = uni.getSystemInfoSync()

import { ref } from 'vue'
const avatar = ref(AVATAR_URL as string)
const username = ref('Crissy-月下闲人' as string)
const itemList = ref([
  {
    title: '待服务',
    icon: 'icon-order',
    count: 0,
  },
  {
    title: '进行中',
    icon: 'icon-order',
    count: 0,
  },
  {
    title: '待付款',
    icon: 'icon-order',
    count: 0,
  },
  {
    title: '历史服务',
    icon: 'icon-order',
    count: 0,
  },
] as any[])

const svgList: Array<any> = [
  {
    title: '分享赚钱',
    icon: '/static/svg/红包.png',
  },
  {
    title: '就诊人管理',
    icon: '/static/svg/就诊人.png',
  },
  {
    title: '优惠卷',
    icon: '/static/svg/优惠卷.png',
  },
  {
    title: '我的收藏',
    icon: '/static/svg/收藏.png',
  },
  {
    title: '个人信息',
    icon: '/static/svg/个人信息.png',
  },
  {
    title: '关于我们',
    icon: '/static/svg/关于我们.png',
  },
]
</script>

<template>
  <view class="page">
    <Floating class="floating"></Floating>
    <view :style="{ paddingTop: safeAreaInsets?.top + 'px' }" class="page-header">
      <view class="header-content">
        <view class="avatar-box">
          <image :src="avatar" class="avatar" mode="scaleToFill" />
        </view>
        <text class="username">{{ username }}</text>
      </view>
    </view>
    <view class="page-content">
      <view>
        <view class="content-box-1">
          <view class="order-box">
            <text class="order-title">服务订单</text>
            <view class="svg-box">
              <text>全部订单</text>
              <image class="refresh-icon" src="/static/svg/goto.png"></image>
            </view>
          </view>
          <view class="order-info">
            <view v-for="item in itemList" class="order-item">
              <text class="order-item-count">{{ item.count }}</text>
              <text class="order-item-title">{{ item.title }}</text>
            </view>
          </view>
        </view>
        <view class="content-box-2">
          <view class="fun-box">
            <view v-for="item in svgList" :key="item" class="fun-item">
              <image :src="item.icon" class="fun-item-svg" />
              <text class="fun-item-title">{{ item.title }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
$page-header-height: 450rpx;
$page-color: #ccc;
$page-content-color: #f2f8f7;

$bg-1: linear-gradient(-45deg, #f7f1ff 0%, #e7ffec 20%, #d1f9e7 39%, #bcd2e7 76%, #b8d0e5 100%);

.page {
  width: 100%;
  height: 100vh;
  background: $bg-1;
}
.floating {
  width: 100px;
  height: 100px;
}

.page-header {
  height: $page-header-height;

  .header-content {
    width: 100%;
    height: $page-header-height;
    display: flex;
    position: relative;

    .avatar-box {
      $avatar-size: 200rpx;
      width: $avatar-size;
      height: $avatar-size;

      position: absolute;
      left: 30rpx;
      bottom: 100rpx;

      .avatar {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }

    .username {
      font-size: 40rpx;
      font-weight: bold;
      color: #fff;
      font-family: 'Courier New', Courier, monospace;
      position: absolute;
      left: 270rpx;
      bottom: 200rpx;
    }
  }
}

.page-content {
  height: calc(100vh - $page-header-height);
  background-color: $page-content-color;
  border-top-right-radius: 50rpx;
  border-top-left-radius: 50rpx;
  z-index: 9;
  position: relative;
  padding: 55rpx 30rpx;

  .content-box-1 {
    width: 100%;
    height: 360rpx;
    border-radius: 30rpx;
    background: #fff;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    padding: 20rpx 50rpx;

    .order-box {
      width: 100%;
      height: 40%;
      border-bottom: 1rpx solid #ccc;
      display: flex;
      align-items: center;

      position: relative;

      .order-title {
        font-size: 40rpx;
        color: #618a72;
      }

      .svg-box {
        position: absolute;
        right: 0;
        display: flex;
        align-items: center;
        color: #999;

        .refresh-icon {
          width: 40rpx;
          height: 40rpx;
        }
      }
    }

    .order-info {
      display: flex;
      width: 100%;
      height: 60%;
      align-items: center;
      justify-content: space-around;

      .order-item {
        display: flex;
        flex-wrap: wrap;
        text-align: center;

        .order-item-count {
          width: 100%;
          font-size: 60rpx;
        }

        .order-item-title {
          width: 100%;
          font-size: 30rpx;
          color: #618a72;
        }
      }
    }
  }

  .content-box-2 {
    margin-top: 30rpx;
    width: 100%;
    border-radius: 30rpx;
    background: #fff;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    padding: 20rpx 50rpx;

    display: flex;
    justify-content: center;
    align-items: center;
  }
}

.fun-box {
  $svg-size: 50rpx;
  $fun-item-font-size: 25rpx;

  display: flex;
  flex-wrap: wrap;
  width: 100%;
  min-height: 280rpx;
  align-items: center;
  justify-content: space-around;

  .fun-item {
    display: flex;
    width: 150rpx;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;

    .fun-item-svg {
      width: $svg-size;
      height: $svg-size;
    }

    .fun-item-title {
      margin-top: 10rpx;
      width: 100%;
      font-size: $fun-item-font-size;
      color: #222;
    }
  }
}
</style>
